Skip to main content

Common recipes for using GitHub Copilot

So, what are some common recipes for using GitHub Copilot?

  • Generating boilerplate code (e.g., CRUD operations). This is Copilot at its best. It can generate a lot of code for you, and you can use it to create a lot of boilerplate code quickly. Really valuable when you want to create a lot of code quickly, for a new project or want to experiment with a new library or framework.
  • Writing tests. Tests are a must and with Copilot you can generate a lot of tests quickly. You can use it to create unit tests, integration tests, and even end-to-end tests. This is a great way to get started with testing and to learn how to write tests.
  • Automating repetitive tasks (e.g., batch renaming variables). This is a great way to save time and to avoid doing the same thing over and over again. You can use it to rename variables, functions, classes, and even files. Another great use case is to use it to generate documentation for your code.

There are different types of commands that can help with these tasks:

  • @ context variables: These are commands that you can use to get information about your code. For example, you can use @codebase to get information about the codebase, or @workspace to get information about the workspace. These commands are really useful when you want to get information about your code quickly.
  • # chat variables: These are commands that you can use to get information about your code. For example, you can use #changes to get information about the changes in your code, or #file to get information about a specific file.
  • / slash commands: These are commands that you can use to get information about your code. For example, you can use /docs to get information about the documentation, or /fix to get information about the fixes in your code. They often work like a prompt.